<div class="layui-fluid layui-anim website-anim" id="website-blackList" lay-title="黑名单管理">
    <div class="layui-row website-container">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body website-table-full">
                    <form class="layui-form layui-table-form" lay-filter="blackList-table-form">
                        <div class="layui-row">
                            <div class="layui-col-md12">
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label layui-form-label-sm">姓名</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="name" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label layui-form-label-sm">证件类型</label>
                                        <div class="layui-input-inline">
                                            <select name="identityTypeCode">
                                                <option value="">请选择</option>
                                                <option
                                                        th:each="item : ${zjlxList}"
                                                        th:value="${item.code}" th:text="${item.name}">
                                                </option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label layui-form-label-sm">职务</label>
                                        <div class="layui-input-inline">
                                            <select name="positionTypeCode">
                                                <option value="">请选择</option>
                                                <option
                                                        th:each="item : ${positionTypeList}"
                                                        th:value="${item.code}" th:text="${item.name}">
                                                </option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label layui-form-label-sm">职称级别</label>
                                        <div class="layui-input-inline">
                                            <select name="titleTypeCode">
                                                <option value="">请选择</option>
                                                <option
                                                        th:each="item : ${titleTypeList}"
                                                        th:value="${item.code}" th:text="${item.name}">
                                                </option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-col-md-offset10">
                                <div class="layui-btn layui-btn-sm layui-btn-primary website-button-blue-plain table-action" id="query">
                                    查询
                                </div>
                                <div class="layui-btn layui-btn-sm layui-btn-primary website-button-green-plain table-action" id="reset">
                                    重置
                                </div>
                                <div class="layui-btn layui-btn-sm layui-btn-primary website-button-green-plain table-action" shiro:hasAnyPermissions="blackList:add" id="blackListAdd">
                                    新增
                                </div>
                           </div>
                        </div>
                    </form>
                    <table lay-filter="blackListTable" lay-data="{id: 'blackListTable'}"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="blackList-option">
    <span shiro:lacksPermission="blackList:list,blackList:update,blackList:delete">
        <span class="layui-badge-dot website-bg-orange"></span> 无权限
    </span>
    <a lay-event="detail" shiro:hasPermission="blackList:list" class="website-green">查看</a>
    <a lay-event="edit" shiro:hasPermission="blackList:update" class="website-blue">编辑</a>
    <a lay-event="del" shiro:hasPermission="blackList:delete" class="website-red">删除</a>
</script>
<script type="text/html" id="sex-name">
    {{#
    var dict=layui.dict.getByCode(d.sexTypeCode);
    }}
    {{#  if(dict){ }}
    <span>{{ dict.name }}</span>
    {{#  } }}
</script>
<script type="text/html" id="identity-name">
    {{#
    var dict=layui.dict.getByCode(d.identityTypeCode);
    }}
    {{#  if(dict){ }}
    <span>{{ dict.name }}</span>
    {{#  } }}
</script>
<script type="text/html" id="position-name">
    {{#
    var dict=layui.dict.getByCode(d.positionTypeCode);
    }}
    {{#  if(dict){ }}
    <span>{{ dict.name }}</span>
    {{#  } }}
</script>
<script type="text/html" id="title-name">
    {{#
    var dict=layui.dict.getByCode(d.titleTypeCode);
    }}
    {{#  if(dict){ }}
    <span>{{ dict.name }}</span>
    {{#  } }}
</script>
<script data-th-inline="none" type="text/javascript">
    layui.use(['jquery', 'form', 'table', 'website','dict'], function () {
        var $ = layui.jquery,
            website = layui.website,
            form = layui.form,
            table = layui.table,
            dict = layui.dict,
            $view = $('#website-blackList'),
            $query = $view.find('#query'),
            $reset = $view.find('#reset'),
            $blackListAdd = $view.find('#blackListAdd'),
            $searchForm = $view.find('form'),
            sortObject = {field: 'createTime', type: null},
            tableIns,
            createTimeFrom,
            createTimeTo;


        form.render();
        initTable();
        table.on('tool(blackListTable)', function (obj) {
            var data = obj.data,
                layEvent = obj.event;
            if (layEvent === 'detail') {
                website.modal.view('详细信息', 'biz/blackList/blackListDetail/' + data.blackListId, {
                    area: $(window).width() <= 750 ? '95%' : '660px'
                });
            }
            if (layEvent === 'del') {
                website.modal.confirm('删除信息', '确定删除该信息？', function () {
                    deleteExperts(data.blackListId);
                });
            }
            if (layEvent === 'edit') {
                website.modal.open('修改信息', 'biz/blackList/blackListUpdate/' + data.blackListId, {
                    area: $(window).width() <= 750 ? '90%' : '50%',
                    offset: '30px',
                    btn: ['提交', '取消'],
                    yes: function (index, layero) {
                        $('#blackList-update').find('#submit').trigger('click');
                    },
                    btn2: function () {
                        layer.closeAll();
                    }
                });
            }
        });
        table.on('sort(blackListTable)', function (obj) {
            sortObject = obj;
            tableIns.reload({
                initSort: obj,
                where: $.extend(getQueryParams(), {
                    field: obj.field,
                    order: obj.type
                })
            });
        });
        $query.on('click', function () {
            var params = $.extend(getQueryParams(), {field: sortObject.field, order: sortObject.type});
            tableIns.reload({where: params, page: {curr: 1}});
        });

        $reset.on('click', function () {
            $searchForm[0].reset();
            sortObject.type = 'null';
            createTimeTo = null;
            createTimeFrom = null;
            tableIns.reload({where: getQueryParams(), page: {curr: 1}, initSort: sortObject});
        });
        $blackListAdd.on('click', function () {
            website.modal.open('新增信息', 'biz/blackList/blackListAdd', {
                btn: ['提交', '重置'],
                area: $(window).width() <= 750 ? '95%' : '50%',
                offset: '30px',
                yes: function (index, layero) {
                    $('#blackList-add').find('#submit').trigger('click');
                },
                btn2: function () {
                    $('#blackList-add').find('#reset').trigger('click');
                    return false;
                }
            });
        });
        function initTable() {
            tableIns = website.table.init({
                elem: $view.find('table'),
                id: 'blackListTable',
                url: ctx + 'blackList/list',
                cols: [[
                    { type: 'numbers', title: '序号',minWidth: 20},
                    {field: 'name', title: '姓名',minWidth: 70 },
                    {title: '证件类型',templet: '#identity-name',minWidth: 60 },
                    {field: 'identity', title: '证件号',minWidth: 170 },
                    {title: '性别',templet: '#sex-name' ,minWidth: 20},
                    {title: '行政职务',templet: '#position-name',minWidth: 100},
                    {title: '职称级别',templet: '#title-name',minWidth: 100},
                    {field: 'telephone', title: '座机',minWidth: 100},
                    {field: 'mobile', title: '手机',minWidth: 100},
                    {title: '操作', toolbar: '#blackList-option', minWidth: 200}
                ]]
            });
        }
        function getQueryParams() {
            var params = $searchForm.serializeJson();
            var createTime = params.time;
            if (createTime) {
                createTimeFrom = createTime.split(' - ')[0];
                createTimeTo = createTime.split(' - ')[1];
            }
            params.invalidate_ie_cache = new Date();
            params.createTimeFrom = createTimeFrom;
            params.createTimeTo = createTimeTo;
            return params;
        }
        function deleteExperts(blackListId) {
            website.post(ctx + 'blackList/delete/' + blackListId, null, function () {
                website.alert.success('删除成功');
                $query.click();
            });
        }
    })
</script>